import { defineStore } from 'pinia'
import { ref } from 'vue'

export const useDictStore = defineStore('dict', () => {
  const dict = ref<any>(null)

  const setDict = (val: any) => {
    dict.value = val
  }

  const getDict = () => {
    return dict.value
  }

  return { setDict, getDict }
},
{
  persist: {
    // 调整为兼容多端的API
    storage: {
      setItem(key, value) {
        uni.setStorageSync(key, value)
      },
      getItem(key) {
        return uni.getStorageSync(key)
      },
    },
  },
},)
